package com.whcoding.designpatterns.pattern.strategy;

/**
 * @program: spring-boot-learning
 * @description: 具体策略角色：折扣百分比
 * @author: whcoding
 * @create: 2022-09-20 20:03
 **/
public class PercentageStrategy extends AbstractDiscountStrategy {
	/**
	 * 折扣百分比
	 */
	private double discountPercent;

	public PercentageStrategy(double price, int copies) {
		super(price, copies);
	}

	/**
	 * Sets the discountPercent
	 *
	 * @param discountPercent discountPercent
	 */
	public void setDiscountPercent(double discountPercent) {
		this.discountPercent = discountPercent;
	}

	/**
	 * 数量*单件*折扣比例
	 * @return
	 */
	@Override
	double calcDiscount() {
		return getCopies() * getPrice() * discountPercent;
	}
}
